import {StyleSheet,Button, Text, View} from 'react-native';
import { TabView, SceneMap } from 'react-native-tab-view';
import {useEffect, useState} from "react";
import PagerView from "react-native-pager-view";
import DataDay from "./DataTime/DataDay";
import DataWeek from "./DataTime/DataWeek";
import Take from "./Take";

export default function DataList({navigation}) {
    const [index, setIndex] = useState(0);
    const [routes] = useState([
        { key: 'day', title: 'First' },
        { key: 'week', title: 'Second' },
    ]);

    useEffect(()=>{
        if(index === 0){
            navigation.setOptions({title:"今日采集"})
        }
        if(index === 1){
            navigation.setOptions({title:"本周采集"})
        }
        navigation.setOptions({headerRight:()=><Text style={styles.signText} onPress={()=>navigation.navigate('Sign')}> 登陆 </Text>})
    },[index])
    return (
        <TabView
            renderTabBar={() => null}
            navigationState={{ index, routes }}
            renderScene={SceneMap({
                day: ()=><DataDay navigation={navigation} /> ,
                week: ()=> <DataWeek navigation={navigation} />
            })}
            onIndexChange={setIndex}
            initialLayout={{ width: 10 }}
        />
    )
}
const styles = StyleSheet.create({
    signText:{
        color:'#1C90D1',
        fontSize:15,
        fontWeight:"bold"
    },

});




